package com.funny1.registrypostprocessor;

import com.funny1.app.Eoo;
import com.funny1.app.Roo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author fanxiao  2021/8/23
 * @since 1.0.0
 */
@Slf4j
public class RooBeanDefinitionRegistryPostProcessor implements BeanDefinitionRegistryPostProcessor {

	@Override
	public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
		log.info("register roo");
//		BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(Roo.class);
//
//		beanDefinitionBuilder.addPropertyValue("name", "Hello");
//		beanDefinitionBuilder.addPropertyReference("eoo", "eoo");
//		beanDefinitionBuilder.setScope(BeanDefinition.SCOPE_SINGLETON);
//		beanDefinitionBuilder.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
//    	AbstractBeanDefinition rooRawBeanDefinition = beanDefinitionBuilder.getRawBeanDefinition();
//		registry.registerBeanDefinition("roo", rooRawBeanDefinition);
	}

	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

	}
}
